package com.linkvin.ec.hcs.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.linkvin.ec.hcs.dao.model.mdm.bo.RetailorBo;
import com.linkvin.ec.hcs.service.mdm.RetailorService;
import com.linkvin.ec.hcs.vo.RestVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/retailor", produces = MediaType.APPLICATION_JSON_VALUE)
public class RetailorController {

    private static final Logger LOGGER = LoggerFactory.getLogger(RetailorController.class);

    @Autowired
    private RetailorService retailorService;

    @PostMapping(value = "/queryPage")
    public RestVO<Page<RetailorBo>> queryRetailorList(@RequestBody Page<RetailorBo> page){
        RestVO<Page<RetailorBo>> result = new RestVO<>(0,"success");
        LOGGER.info("RetailorController.queryRetailorList params : {}", page);
        try{
            page = retailorService.queryPageRetailor(page);
            result.setData(page);
        }catch(Exception ex)
        {
            LOGGER.error("RetailorController.queryRetailorList ERROR Message : {} ", ex.getMessage());
            result.setCode(30004);
            result.setMessage("二网查询错误");
        }
        return result;
    }
}
